/**
 * @author Haidar Osman
 */

function removeClass(label) {
	var node = $("#classTree").dynatree("getTree").getNodeByKey(label)
	if(node) {
		node.remove();
	}

	// var rootNode = $("#viewTree").dynatree("getRoot");
	// rootNode.removeChildren();
}

function removeItem(label) {
	removeClass(label);
}

function removeView(label) {
	// $("#tree").dynatree("getTree").getNodeByKey("1234").select();
	var node = $("#viewTree").dynatree("getTree").getNodeByKey(label)
	if(node) {
		node.remove();
	}
}

function setClassName(oldClassName, newClassName) {
	var node = $("#classTree").dynatree("getTree").getNodeByKey(oldClassName);
	if(node) {
		node.data.title = newClassName;
		node.data.key = newClassName;
		node.render();
	}
}

function addClass(label) {
	var rootNode = $("#classTree").dynatree("getRoot");
	// Call the DynaTreeNode.addChild() member function and pass options for the new node
	var childNode = rootNode.addChild({
		title : label,
		key : label,
		isFolder : false
	});
}

function addItem(label) {

	addClass(label);
}

function addView(label) {
	var rootNode = $("#viewTree").dynatree("getRoot");
	// Call the DynaTreeNode.addChild() member function and pass options for the new node
	var childNode = rootNode.addChild({
		key : label,
		title : label,
		isFolder : false
	});
}

// function test(id)
// {
// alert($("li:contains("+id+")"));
// }